Scheduling is the method by which threads, processes, or data flows are given access to system resources such as processor time, communications bandwidth, etc. The intent of a scheduler is to perform multitasking and multiplexing of the jobs. The same requirement holds true for scheduling jobs running within an enterprise web application. The applications that consume system resources such as processor time and memory can be managed by a scheduler in different ways based on the type of workloads. A central problem in designing a multi-threaded enterprise application is to find out the appropriate scheduling algorithm that decides which task needs to be executed next in a heavily loaded environment. One approach is to create a thread pool per application and schedule the workloads only through the available threads. The thread pool allocation for different applications should be based on the total capacity the system can withstand. This approach achieves the fair sharing of threads across the application. But is highly inefficient in terms of utilization of system threads.
Another approach is to keep a single thread pool for the whole system and different applications use the same pool to schedule their workloads. This approach allocates system resources based on a first-come first-served basis. Whenever a new thread is released to the pool, the scheduler picks up a job from its waiting list and allocates the thread to it to complete the job. This approach is more efficient in terms of resource utilization, but fails to achieve fair share between applications because it can so happen that continuous creation of jobs from an application can result in resource starvation for other applications.